package com.etung.iot.demo.controller;

import com.etung.iot.demo.core.Authorized;
import com.etung.iot.demo.services.AlarmService;
import com.etung.iot.demo.vo.Result;
import com.etung.iot.demo.vo.req.AlarmReq;
import com.etung.iot.demo.vo.req.ProjectReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/alarm")
@Api(tags = "报警接口")
public class AlarmController {
    @Autowired
    private AlarmService alarmService;

    @Authorized
    @PostMapping("/selectAlarm")
    @ApiOperation(value = "查询待确认报警")
    public Result<?> selectAlarm(@RequestBody AlarmReq alarmReq){
        return Result.OK(alarmService.listData(alarmReq));
    }

    @Authorized
    @PostMapping("/ackAlarm")
    @ApiOperation(value = "确认报警")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "报警ID", required = true, dataType = "String"),
    })
    public Result<?> ackAlarm(@RequestBody String ids){
        alarmService.ackAlarm(ids);
        return Result.OK();
    }
}
